package com.cw.jeeyt.dao.impl.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.cw.jeeyt.dao.intf.system.SystemAttachRelationDao;
import com.cw.jeeyt.dao.mapper.system.SystemAttachRelationMapper;
import com.cw.jeeyt.dao.model.system.SystemAttachRelationDo;
import com.cw.lang.common.utils.PageUtil;
import com.cw.lang.common.pagehelper.PageHelper;
import com.cw.lang.mybatis.dto.PageInfo;

/**
 * 附件关联关系 dao数据库操作接口
 *
 * @author chenw
 * @version 1.0.0
 */
@Repository
public class SystemAttachRelationDaoImpl implements SystemAttachRelationDao {
    @Autowired
    private SystemAttachRelationMapper systemAttachRelationMapper;

    /**
     * 删除附件关联关系
     *
     * @param systemAttachRelation
     */
    @Override
    public void delete(SystemAttachRelationDo systemAttachRelation) {
        systemAttachRelationMapper.delete(systemAttachRelation);
    }

    /**
     * 修改附件关联关系
     *
     * @param systemAttachRelation
     */
    @Override
    public void update(SystemAttachRelationDo systemAttachRelation) {
        systemAttachRelationMapper.update(systemAttachRelation);
    }

    /**
     * 根据主键查询附件关联关系
     *
     * @param id 主键id
     * @return 附件关联关系
     */
    @Override
    public SystemAttachRelationDo getById(String id) {
        return systemAttachRelationMapper.getById(id);
    }

    /**
     * 新增附件关联关系
     *
     * @param systemAttachRelation
     * @return 整数
     */
    @Override
    public Integer insert(SystemAttachRelationDo systemAttachRelation) {
        return systemAttachRelationMapper.insert(systemAttachRelation);
    }

    /**
     * 查询所有附件关联关系
     *
     * @return 附件关联关系集合
     */
    @Override
    public List<SystemAttachRelationDo> querySystemAttachRelationList() {
        return systemAttachRelationMapper.querySystemAttachRelationList();
    }

    /**
     * 分页查询附件关联关系
     *
     * @param systemAttachRelation 查询条件
     * @param startNum 开始条数
     * @param pageSize 每页长度
     * @return 附件关联关系集合
     */
    @Override
    public PageInfo<SystemAttachRelationDo> queryByPage(SystemAttachRelationDo systemAttachRelation, Integer startNum,
        Integer pageSize) {
        PageHelper.startPage(PageUtil.calPageNum(startNum, pageSize), pageSize);
        return new PageInfo<>(systemAttachRelationMapper.queryByPage(systemAttachRelation));
    }

    /**
     * 删除附件
     *
     * @param systemAttachRelation
     * @throws Exception
     */
    @Override
    public void deleteByObjectIdAndAttachId(SystemAttachRelationDo systemAttachRelation) {
        systemAttachRelationMapper.deleteByObjectIdAndAttachId(systemAttachRelation);
    }

}
